package com.sen.common.common.response;

import com.sen.common.common.inter.RespCodeEnum;
import lombok.Data;

import java.io.Serializable;

@Data
public class Body<T> implements Serializable {

    private int code;
    private String msg;
    private Boolean success;
    private T data;

    public void setBodySuccess(T data) {
        this.code = ResultMsgEnum.SUCCESS.getCode();
        this.msg = ResultMsgEnum.SUCCESS.getMsg();
        this.success = ResultMsgEnum.SUCCESS.isSuccess();
        this.data = data;
    }

    public void setBody(T data, RespCodeEnum bodyMsgEnum) {
        this.code = bodyMsgEnum.getCode();
        this.msg = bodyMsgEnum.getMsg();
        this.success = bodyMsgEnum.isSuccess();
        this.data = data;
    }
}
